package com.martin.lib_base.bean

import android.os.Parcel
import android.os.Parcelable
import androidx.databinding.BaseObservable
import java.io.Serializable

/**
 * @author：Houge
 * @date：2023/2/17
 * @desc：
 */
class UserBean() : BaseObservable(), Parcelable, Serializable {
    var id: Int? = null
    var token: String? = ""
    var avatar: String? = ""
    var name: String? = ""
    var user_nicename: String? = ""
    var mobile: String? = ""
    var user_code: String? = ""

    constructor(parcel: Parcel) : this() {
        id = parcel.readInt()
        token = parcel.readString()
        avatar = parcel.readString()
        name = parcel.readString()
        user_nicename = parcel.readString()
        mobile = parcel.readString()
        user_code = parcel.readString()
    }

    // 序列化
    override fun writeToParcel(parcel: Parcel, flags: Int) {
        id?.let { parcel.writeInt(it) }
        parcel.writeString(token)
        parcel.writeString(avatar)
        parcel.writeString(name)
        parcel.writeString(user_nicename)
        parcel.writeString(mobile)
        parcel.writeString(user_code)
    }

    /**
     * 描述
     * 返回的是内容的描述信息
     * 只针对一些特殊的需要描述信息的对象,需要返回1,其他情况返回0就可以
     *
     * @return
     */
    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<UserBean> {
        override fun createFromParcel(parcel: Parcel): UserBean {
            return UserBean(parcel)
        }

        override fun newArray(size: Int): Array<UserBean?> {
            return arrayOfNulls(size)
        }
    }

}